import { postGetEnum } from "@/basa/api";

export default {
  name: "contract-approval-manage",
  data() {
    return {
      isActive: 0,
      focuses: [
        { focus: "approvalAll" }, //全部
        { focus: "approvalPending" }, //待提交
        { focus: "approvalPass" } //审批中
      ],
      // 非锁定表格
      unfixedTableThead: [
        {
          label: "审批类型",
          prop: "todoData.businessBillTypeName",
          width: "120"
        },
        {
          label: "合同正式编号",
          prop: "businessData.formalContractCode",
          width: "120"
        },
        {
          label: "合同名称",
          prop: "businessData.contractName",
          width: "200"
        },
        {
          label: "供应商1",
          prop: "businessData.partyBName",
          width: "180"
        },
        {
          label: "供应商2",
          prop: "businessData.partyBNameBak",
          width: "180"
        },
        {
          label: "合同签订单位(甲方)",
          prop: "businessData.partyAName",
          width: "200"
        },
        {
          label: "填报单位",
          prop: "businessData.reportInOrgName",
          width: "200"
        },
        {
          label: "合同金额（含税）",
          prop: "businessData.initTotalContractPriceIncludeTaxString",
          align: "right",
          width: "140"
        },
        {
          label: "币种",
          prop: "businessData.currencyName",
          width: "80"
        },
        {
          label: "编制人",
          prop: "businessData.compileUser",
          width: "80"
        },
        {
          label: "编制日期",
          prop: "businessData.compileDate",
          width: "120",
          formatterName: 'wirteTimeHandler'
        },
        // {
        //   label: "合同状态",
        //   prop: "businessData.contractStateStr",
        //   width: "70"
        // },
        {
          label: "审批状态",
          prop: "todoData.workItemStatusString",
          width: "70"
        }
      ],
      currencyList: []
    };
  },
  methods: {
    // 页签跳转
    tabChange(data, index) {
      console.log("tab:", data);
      this.$router.push(`/contractManagement/materialRentContractApproval/${data}`);
    },
    // 跳转审批
    goApproval(row, index) {
      const { businessData, todoData } = row;
      this.$store.dispatch("setBusinessList", todoData);
      const businessList = JSON.stringify(todoData);
      sessionStorage.setItem("businessList", businessList);
      const { businessBillTypeCode } = todoData;
      const { id, protocolId, contractName } = businessData;
      if (businessBillTypeCode == "S0108") {
        this.$router.push({
          path: "/contractManagement/materialRentContractApproval/materialRentContractAgreementDetail",
          query: {
            concId: id,
            protocolId: protocolId,
            ifApprovingStatus: 1,
            type: 'approval'
          }
        });
        return;
      }
      const jumpUrl = {
        S0105: "/contractManagement/materialRentContractApproval/contractDraftDetail/",
        S0106: "/contractManagement/materialRentContractApproval/contractChangeDetail/"
      };
      this.$router.push({
        path: `${jumpUrl[businessBillTypeCode]}${id}`,
        query: {
          name: contractName,
          type: 'approval'
        }
      });
    },
    // 详情
    goDetail(row, index) {
      const { businessData, todoData } = row;
      const { businessBillTypeCode } = todoData;
      const { id, protocolId } = businessData;
      if (businessBillTypeCode == "S0108") {
        this.$router.push({
          path: "/contractManagement/materialRentContractAgreement/item-detail",
          query: {
            concId: id,
            protocolId: protocolId,
            type: 'approval'
          }
        });
        return;
      }
      const jumpUrl = {
        S0105: "/contractManagement/materialRentContractDraft/item-detail/",
        S0106: "/contractManagement/materialRentContractChange/contractChangeDetail/"
      };
      this.$router.push({
        path: `${jumpUrl[businessBillTypeCode]}${id}`,
        query: {
          type: 'approval'
        }
      });
    }
  },
  created() {
    postGetEnum("getCurrencyTypeDict").then(res => {
      this.currencyList = res.data.data;
    });
  }
};
